package com.ithei.多线程第二天.原子性;

import com.ithei.多线程第二天.牛奶模型.Demo;

public class Demo1 implements Runnable {
    public int count=0;
    @Override
    public void run() {

        synchronized ("as") {
            for (int i = 0; i < 100; i++) {
                count++;
                System.out.println(count);
            }
        }
    }
}

class Test{
    public static void main(String[] args) {
        Demo1 demo=new Demo1();
        for (int i = 0; i < 1000; i++) {
            new Thread(demo).start();
        }
    }
}
